<template>
    <div>
        <el-col
            :span="20"
            v-for="(user,index) in apply"
            :key="user.userId"
            :offset="index =0"
        >
            <el-card>
                <div>
                        <div class="bottom clearfix">
                            <span class="left">userId:{{user.userId}}</span><br><br><br><span class="left">用户名:{{user.userName}}</span><br><br><br><span class="left">{{user.userKind}}</span>
                            <span class="right">
                                <el-button type="primary" plain v-on:click="agree(user)">同意</el-button>
                                <el-button type="danger" plain v-on:click="refused(user)">拒绝</el-button>
                            </span>
                        </div>
                </div>
            </el-card>
        </el-col>
    </div>
</template>

<script>
export default {
    name:"Approval",
    data() {
        return {
          currentDate: new Date(),
          apply:[],
          user:{}
      };
      
    },
    methods:{
        agree(user){          
            this.$axios.post("http://localhost:9090/mynewsweb/api/agreeApply",user).then((res) => {
                if (res.data.state) {
                    alert(res.data.msg);                   
                   this.showApply();
                } else {
                    alert(res.data.msg);
                    }
            });
        },
        refused(user){
            this.$axios.post("http://localhost:9090/mynewsweb/api/disagreeApply",user).then((res) => {
                if (res.data.state) {
                    alert(res.data.msg);
                    this.showApply();
                } else {
                    alert(res.data.msg);
                    }
            });
        },  
        showApply(){
             var _this=this;
            this.$axios.get("http://localhost:9090/mynewsweb/api/userApply").then((res) => {
          _this.apply=res.data;
        });
        }  
        },
        created(){       
       this.showApply();
    }
}
</script>

<style>
  .con{
    padding-left: 160px;
    position:relative;
  }
  .clearfix:before,
  .clearfix:after {
      display: table;
      content: "";
  }
  
  .clearfix:after {
      clear: both
  }
  .bottom {
    margin-top: 13px;
    line-height: 12px;
  }
  .left{
    float: left;
  }

  .right{
    float: right;
  }

</style>